<script setup>
import { reactive, ref } from "vue";
import { addNoter } from "../../api/node";
import { useUserStore } from "../../stores/counter";
// 信息提示框
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
const token = ref(useUserStore().userMsg.token);
const router = useRouter();
const userData = reactive({ data: {} });

console.log(addNoter);

// 点击发布的时候
function Submit(row) {
  row.token = token.value;
  addNoter(row).then((res) => {
    console.log(res.data);
    if (res.data.code === 2) {
      ElMessage: ({
        msg: "添加成功",
        type: "info",
      });
      router.push("/system");
    }
  });
  // emits("getNewData", userData.data);
}
</script>

<template>
  <div>
    <h1 class="notice">基本信息</h1>
    <br />
    <el-form reactive="loginRefrule" :model="resetForm" label-width="120px">
      <el-form-item label="任务标题">
        <el-input v-model="userData.title" />
      </el-form-item>

      <el-form-item label="任务详情">
        <el-input v-model="userData.content" type="textarea" />
      </el-form-item>
      <el-form-item>
        <!-- scope是饿了嘛组件库的一个属性，里面包括了索引值 -->
        <el-button type="primary" @click="Submit(userData)">发布</el-button>
        <el-button @click="resetForm(userData)">取消</el-button>
        <!--不用管 -->
        <el-button @click="$router.push({ path: '/system' })">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<style scoped>
.demo-form-inline {
  padding-left: 50px;
}
</style>
